package com.landary.parameterrplacement.service;

import com.landary.parameterrplacement.entity.Post;
import com.landary.parameterrplacement.utils.XmlToMapUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @author 刘欣
 * @createTime 2023/8/14 8:49
 * @description
 */
@Service
public class AnalysisPostXmlService {

    public List<Post> xmlToMaP(String xml, String tagName) throws Exception {
        List<Map<String, String>> listMap = (List<Map<String, String>>) XmlToMapUtils.xmlToMap(xml, tagName);
        List<Post> posts = Post.getPost(listMap);
        if (posts == null || posts.size() == 0) {
            throw new Exception("xml解析有误");
        }
        return posts;
    }
}
